// app.js
const {cloudId} = require('./config');
const plugin = requirePlugin("edu-core");
const emitter = plugin.emitter;
App({
  onLaunch() {
   // console.log(cloudId)
    wx.cloud.init({
      env:cloudId,
      traceUser: true
    })
    this.serviceInit();
    this.InitCustom();
  },
  InitCustom() {
    console.log('调用窗口计算')
    wx.getSystemInfo({
      success: e => {
        //console.log(e)
        this.globalData.StatusBar = e.statusBarHeight;
        let custom = wx.getMenuButtonBoundingClientRect();
        // console.log(custom)
        this.globalData.Custom = custom;
        this.globalData.CustomBar = custom.bottom + custom.top - e.statusBarHeight;
        let capsule = wx.getMenuButtonBoundingClientRect();
        if (capsule) {
          this.globalData.displayArea = {
            windowHeight: e.windowHeight,
            windowWidth: e.windowWidth,
            screenHeight: e.screenHeight,
          };
          this.globalData.Custom = capsule;
          this.globalData.CustomBar =
            capsule.bottom + capsule.top - e.statusBarHeight;
        } else {
          this.globalData.CustomBar = e.statusBarHeight + 50;
        }
      }
    })
  },
  serviceInit(){
    wx.cloud.callFunction({
      name:'cloud-service-init',
      complete:res=>{
       // console.log(res.result)
        let tdata = res.result.data;
        console.log(tdata)
        this.globalData = tdata;
        emitter.emit('app-reload',null);
      }
    })
  },
  globalData:{},
})